package main

import "fmt"

type Sender interface {
	Send(string) error
}

type AllSender interface {
	Send(string) error
	SendAll([]string) error
}

type EmailSender struct {
	Adder string
	To    string
}

func (s EmailSender) Send(msg string) error {
	fmt.Println("email send: ", msg)
	return nil
}

func (s EmailSender) SendAll(msgs []string) error {
	fmt.Println("email send: ", msgs)
	return nil
}

func main() {
	var sender Sender = EmailSender{"xxx", "yyy"}
	var allsender AllSender = EmailSender{"111", "222"}
	// allsender.Send()
	// allsender.SendAll()

	// allsender 赋值给 sender（allsender包含sender属性）
	sender = allsender
	sender.Send("sss")
	// 断言回allsender接口
	allsender2, ok := sender.(AllSender)
	fmt.Println(allsender2, ok)
	allsender2.SendAll([]string{"xxxxxxx", "zzzzz"})

	esender, ok := sender.(EmailSender)
	fmt.Println(esender, ok)
	fmt.Printf("%T，%#v", esender, esender)

}
